//
//  UserViewController3.m
//  UI_元旦豆瓣
//
//  Created by dllo on 16/1/3.
//  Copyright © 2016年 31付冬梅. All rights reserved.
//

#import "UserViewController3.h"
#import "LTView.h"
//#import "UserViewController.h"
@interface UserViewController3 ()<UITextFieldDelegate>

@end

@implementation UserViewController3
- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        
    }
    return self;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor cyanColor];
    self.title = @"注册";
    LTView *view1 = [[LTView alloc] init];
    view1.frame = CGRectMake(20, 50, 350, 50);
    view1.backgroundColor = [UIColor clearColor];
    view1.myLabel.text = @"用户名";
    view1.myTextField.placeholder = @"请输入用户名";
    view1.myTextField.keyboardType = UIKeyboardTypeNamePhonePad;
    view1.myTextField.delegate = self;
    
    [self.view addSubview:view1];
    
    
    LTView *view2 = [[LTView alloc] init];
    view2.frame = CGRectMake(20, 130, 350, 50);
    view2.backgroundColor = [UIColor clearColor];
    view2.myLabel.text = @"密码";
    view2.myTextField.placeholder = @"请输入密码";
    view2.myTextField.secureTextEntry = YES;
    view2.myTextField.keyboardType = UIKeyboardTypeNumberPad;
    view2.myTextField.delegate = self;
    
    [self.view addSubview:view2];
    
    
    LTView *view3 = [[LTView alloc] init];
    view3.frame = CGRectMake(20, 210, 350, 50);
    view3.backgroundColor = [UIColor clearColor];
    view3.myLabel.text = @"确认密码";
    view3.myTextField.placeholder = @"请再次输入密码";
    view3.myTextField.secureTextEntry = YES;
    view3.myTextField.keyboardType = UIKeyboardTypeNumberPad;
    view3.myTextField.delegate = self;
    
    [self.view addSubview:view3];
    
    
    LTView *view4 = [[LTView alloc] init];
    view4.frame = CGRectMake(20, 290, 350, 50);
    view4.backgroundColor = [UIColor clearColor];
    view4.myLabel.text = @"手机号";
    view4.myTextField.placeholder = @"请输入联系方式";
    view4.myTextField.keyboardType = UIKeyboardTypeNumberPad;
    view4.myTextField.delegate = self;
    
    [self.view addSubview:view4];
    
    
    LTView *view5 = [[LTView alloc] init];
    view5.frame = CGRectMake(20, 370, 350, 50);
    view5.backgroundColor = [UIColor clearColor];
    view5.myLabel.text = @"邮箱";
    view5.myTextField.placeholder = @"请输入邮箱";
    view5.myTextField.keyboardType = UIKeyboardTypeEmailAddress;
    view5.myTextField.delegate = self;
    
    [self.view addSubview:view5];
    
    
    UIButton *button1 = [[UIButton alloc] init];
    button1.frame = CGRectMake(80, 450, 80, 50);
    button1.backgroundColor = [UIColor clearColor];
    [button1 setTitle:@"注册" forState:UIControlStateNormal];
    [button1 setTitleColor:[UIColor magentaColor] forState:UIControlStateNormal];
    [button1 setTitleShadowColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
    [button1 addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button1];
    
    
    UIButton *button2 = [[UIButton alloc] init];
    button2.frame = CGRectMake(230, 450, 80, 50);
    button2.backgroundColor = [UIColor clearColor];
    [button2 setTitle:@"取消" forState:UIControlStateNormal];
    [button2 setTitleColor:[UIColor magentaColor] forState:UIControlStateNormal];
    [button2 setTitleShadowColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
    [button2 addTarget:self action:@selector(buttonAction1:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button2];
    
    
    
    
    
    
    
    
    
    
    
}
- (void)buttonAction1:(UIButton *)button {
    UIAlertController *alert1 = [UIAlertController alertControllerWithTitle:@"取消注册" message:nil preferredStyle:UIAlertControllerStyleAlert];
    UIAlertAction *action1 = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:nil];
        [alert1 addAction:action1];
    [self presentViewController:alert1 animated:YES completion:nil];
}
- (void)buttonAction:(UIButton *)button {
    UIAlertController *alert2 = [UIAlertController alertControllerWithTitle:nil message:@"注册成功" preferredStyle:UIAlertControllerStyleAlert];
    UIAlertAction *action2 = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
//        UserViewController *userView = [[UserViewController alloc] init];
        
        [self dismissViewControllerAnimated:YES completion:^{
            
        }];
    }];

    [alert2 addAction:action2];
    [self presentViewController:alert2 animated:YES completion:nil];
}
//- (void)textFieldDidBeginEditing:(UITextField *)textField {
//    [textField becomeFirstResponder];
//}
- (BOOL)textFieldShouldReturn:(UITextField *)textField {
    
    [textField resignFirstResponder];
    return YES;

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
